import 'data_strength_platform_interface.dart';

class DataStrength {
  Future<String?> getPlatformVersion() {
    return DataStrengthPlatform.instance.getPlatformVersion();
  }

  Future<int?> getMobileSignalStrength() {
    return DataStrengthPlatform.instance.getMobileSignalStrength();
  }

  Future<int?> getWifiSignalStrength() {
    return DataStrengthPlatform.instance.getWifiSignalStrength();
  }

  Future<int?> getWifiLinkSpeed() {
    return DataStrengthPlatform.instance.getWifiLinkSpeed();
  }

  Future<String?> getNetworkType() async {
    return DataStrengthPlatform.instance.getNetworkType();
  }

  static range(data) {
    if (data > -50) {
      return 0;
    } else if (data > -70 && data <= -50) {
      return 1;
    } else if (data > -90 && data < -70) {
      return 2;
    } else {
      return 3;
    }
  }

  /*
  * Great signals are between -30 to -79 dBm,
  * a Good signal would be -80 to -89 dBm,
  * anything -90 to -99 dBm is Average.
  * If your signal is -100 to -109 dBm you are Below average
  * -110 to -120 dBm is Poor.
  * */

  /*
  * 2G (GSM/EDGE): Older and slower network technology.
  * 3G (UMTS/HSPA): An intermediate generation with faster data speeds compared to 2G.
  * 4G (LTE): The current standard for mobile data, offering high-speed internet access.
  * 5G (NR): The latest generation of mobile network technology, providing even faster speeds and lower latency compared to 4G.
  *
  * */

  static mobileRange(data) {
    if (data > -79) {
      return 0;
    } else if (data >= -89 && data <= -80) {
      return 1;
    } else if (data >= -99 && data <= -90) {
      return 2;
    } else if (data >= -109 && data <= -100) {
      return 3;
    } else if (data >= -120 && data <= -110) {
      return 4;
    } else {
      return 5;
    }
  }

  static mobRangeName(data) {
    if (data == null) {
      return "Check internet Turn On";
    }
    int rangeValue = mobileRange(data);
    switch (rangeValue) {
      case 0:
        return "Very High";
      case 1:
        return "High";
      case 2:
        return "Neutral";
      case 3:
        return "Low";
      case 4:
        return "Very Low";
      case 5:
        return "No Internt";

      default:
        break;
    }
  }

  static rangeName(data) {
    if (data == null) {
      return "Check internet Turn On";
    }
    int rangeValue = range(data);
    switch (rangeValue) {
      case 0:
        return "High";
      case 1:
        return "Good";
      case 2:
        return "Low";
      case 3:
        return "No internet";
      default:
        break;
    }
  }
}
